const http  = require('http')

const serve = http.createServer()
//req是请求对象 包含了与客服端相关的数据和属性
serve.on('request',(req,res) =>{
    const url = req.url
    const methods = req.method
    const str = `您请求的地址是 ${url}, 您的请求方式是  ${methods}`
    res.setHeader('Content-Type','text/html;charset=utf8')
    console.log(str);
    //调用res.end()方法 向客户端响应一些内容
    res.end(str)
})
serve.listen(80,()=> {
    console.log('server running at http://127.0.0.1');
})